<template>
    <div class="container-content">
        <el-row>
            <el-col :span="24">
                <h3 class="panel-title">{{rowId?'编辑':'新增'}}投标结果</h3>
            </el-col>
        </el-row>
        <el-divider class="divider"></el-divider>
        <el-form
            ref="formRef"
            :model="formObject"
            label-width="100px"
            label-position="left"
            class="mt20"
        >
            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="标书">
                        <el-input v-model="formObject.bidId"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="投标信息">
                        <el-input v-model="formObject.tenderId"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="投标总结">
                        <el-input v-model="formObject.tenderRemarks"></el-input>
                    </el-form-item>
                </el-col>

                <el-col :span="24">
                    <el-form-item label="中标单位">
                        <el-input v-model="formObject.winBidCompany"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="中标金额">
                        <el-input
                            v-model="formObject.winBidMoney"
                            @change="changeMoney"
                        ></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="中标金额大写">
                        <el-input v-model="formObject.winBidMoneyCh"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="是否中标">
                        <!-- <el-input v-model="formObject.isWinBid"></el-input> -->
                        <el-radio v-model="formObject.isWinBid" label="1" border
                            >是</el-radio
                        >
                        <el-radio v-model="formObject.isWinBid" label="2" border
                            >否</el-radio
                        >
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
    </div>
</template>
<script>
import { convertToRMB } from "@/utils/utils";
import { addResultList,editResultList,getDetailResultList } from "@/api/system/tender";
export default {
    props:['rowId'],
    data() {
        return {
            formObject: {
                bidId: "",
                buyTime: "",
                changeTime: "",
                createTime: "",
                customerId: "",
                id: "",
                tenderId: "",
                token: "",
                userId: "",
                isWinBid: "",
                winBidMoney: "",
                winBidCompany: "",
                winBidMoneyCh: "",
                tenderRemarks: "",
            },
        };
    },
    methods: {
        submit(cb) {
            if(this.rowId){
                editResultList(this.formObject).then((res) => {
                    if (res.code === 200) {
                        this.$message({
                            message: "修改成功！",
                            type: "success",
                        });
                        cb()
                    }
                });
            }else{
                addResultList(this.formObject).then((res) => {
                    if (res.code === 200) {
                        this.$message({
                            message: "新增成功！",
                            type: "success",
                        });
                        cb()
                    }
                });
            }
        },
        changeMoney() {
            this.formObject.winBidMoneyCh = convertToRMB(
                this.formObject.winBidMoney * 1
            );
        },
    },
    mounted() {
        console.log(this.rowId);
        if(this.rowId){
            getDetailResultList(this.rowId).then((res) => {
                if (res.code === 200) {
                    this.formObject = res.data;
                }
            });
        }
    },
};
</script>
<style lang="scss" scoped>
.divider {
    margin: 0;
}
</style>
